/****
   Copyright 2005-2007, Moshe Looks

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
****/

#ifndef FUZZY_REWRITE_H
#define FUZZY_REWRITE_H

#include "rewrite.h"
#include "normal_form.h"

namespace rewrite {
  
  //ReduceLess
  //true<a -> false, a<false -> false, false<true -> true
  //!a<!b -> b<a
  //!a<b lexicographically orders a and b
  //a<!b lexicographically orders a and b
  //note: we could reduce based on (recursively computed) crispness,
  //using a<b <-> !a&b (for crisp exprs); too much work
  template<typename T>
  class ReduceLess  : public RecRule<T> {
  public:
    typedef typename Rule<T>::sib_it sib_it;
    void visit(tree<T>& t,sib_it it) const;
  };
  template<typename T>
  void reduce_less(tree<T>& t) { ReduceLess<T>()(t); }

  //ReduceAlmost
  template<typename T>
  class ReduceAlmost  : public RecRule<T> {
  public:
    typedef typename Rule<T>::sib_it sib_it;
    void visit(tree<T>& t,sib_it it) const;
  };
  template<typename T>
  void reduce_almost(tree<T>& t) { ReduceAlmost<T>()(t); }

} //~namepsace rewrite

#include "fuzzy_rewrite_impl.h"

#endif
